package cn.zxhysy.booksmall.service.impl;

import cn.zxhysy.booksmall.entity.User;
import cn.zxhysy.booksmall.mapper.UserMapper;
import cn.zxhysy.booksmall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

/**
 * @className: UserServiceImpl
 * @description:
 */
@Service
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;

    @Autowired
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User login(User user) {
        Example userExample = new Example(User.class);
        userExample.createCriteria()
                .andEqualTo("name", user.getName())
                .andEqualTo("password", user.getPassword());
        return userMapper.selectOneByExample(userExample);
    }
}
